package edu.sctu.practice.class02.yangshengyu.four10;

import java.util.Scanner;

/**
 * Created by Cullen on 2015/8/13.
 */
public class N50 {
    public static void main(String[] args) {
        System.out.print("请输入年月日:");
        Scanner cin=new Scanner(System.in );
        int year=cin.nextInt();
        cin=new Scanner(System.in );
        int month=cin.nextInt();
        cin=new Scanner(System.in );
        int day=cin.nextInt();
        System.out.println("输入的年份为："+year+"-"+month+"-"+day);
        int ts=0;
        char mt=(char)month;
        String m=String.valueOf(month);
        int l=m.length();
        if(m.length()==1)
        {mt=m.charAt(0);
        }
        else
        {
            if(m.charAt(1)=='0')
            {mt='a';}
            if(m.charAt(1)=='1')
                mt='b';
            if(m.charAt(1)=='2')
                mt='c';
        }
        if(yj(year))
        {
            switch(mt)
            {
                case '1':{ts=0;break;}
                case '2':
                {
                    ts=31;	break;
                }
                case '3':{ts=60;break;}
                case '4':{ts=91;break;}
                case '5':{ts=121;break;}
                case '6':{ts=152;break;}
                case '7':{ts=182;break;}
                case '8':{ts=213;break;}
                case '9':{ts=244;break;}
                case 'a':{ts=274;break;}
                case 'b':{ts=305;break;}
                case 'c':{ts=335;break;}
                default:{}
            }
        }
        else
        {
            switch(mt)
            {
                case '1':
                {ts=0;break;}
                case '2':
                {
                    ts=31;break;
                }
                case '3':
                {ts=59;break;}
                case '4':{ts=90;break;}
                case '5':{ts=120;break;}
                case '6':{ts=151;break;}
                case '7':{ts=181;break;}
                case '8':{ts=212;break;}
                case '9':{ts=243;break;}
                case 'a':{ts=273;break;}
                case 'b':{ts=304;break;}
                case 'c':{ts=334;break;}
                default:{}
            }
        }
        ts=ts+day;
        System.out.print("该日为该年的第"+ts+"天");
    }
    public static boolean yj(int year)
    {
        if(year%100==0&&year%400==0||year%100!=0&&year%4==0)
        {
            return true;
        }
        else
        {return false;}

    }
}
